package com.jilian.powerstation.modul.natives;

import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jilian.powerstation.Constant;
import com.jilian.powerstation.R;
import com.jilian.powerstation.base.BaseFragment;
import com.jilian.powerstation.common.event.MessageEvent;
import com.jilian.powerstation.dialog.nicedialog.BaseNiceDialog;
import com.jilian.powerstation.dialog.nicedialog.NiceDialog;
import com.jilian.powerstation.dialog.nicedialog.ViewConvertListener;
import com.jilian.powerstation.dialog.nicedialog.ViewHolder;
import com.jilian.powerstation.http.SocketConfig;
import com.jilian.powerstation.http.SocketUtils;
import com.jilian.powerstation.modul.adapter.ErrorsListAdapter;
import com.jilian.powerstation.utils.DataUtils;
import com.jilian.powerstation.utils.EmptyUtils;
import com.jilian.powerstation.utils.MainRxTimerUtil;
import com.jilian.powerstation.utils.NumberUtils;
import com.jilian.powerstation.utils.RxTimerUtil;
import com.jilian.powerstation.utils.SPUtil;
import com.jilian.powerstation.utils.StringUtils;
import com.jilian.powerstation.utils.ToastUitl;
import com.jilian.powerstation.utils.rxjava.RxBus;
import com.jilian.powerstation.utils.rxjava.RxBusBean;
import com.jilian.powerstation.views.MainView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static com.jilian.powerstation.Constant.SP_VALUE.DIVICE_SP;

public class OneNativeFragment extends BaseFragment {
    private LinearLayout llTop;
    private RelativeLayout llCenter;
    private LinearLayout llLeft;
    private LinearLayout llRight;
    private LinearLayout llBottom;
    private ImageView imgPower;
    private ImageView imgRight;
    private TextView tvTop;
    private TextView tvBottom;
    private TextView tvLeft;
    private TextView tvRight;
    private TextView tvCenter;
    private TextView tvMode;
    private ImageView ivErrors;

    private MainView mViewMainTop;
    private MainView mViewMainLeft;
    private MainView mViewMainRight;
    private MainView mViewMainDown;
    private TextView tvLine;




    @Override
    protected void loadData() {

    }

    @Override
    protected void createViewModel() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_onenative;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        setNormalTitle("Real-time flow graph", v -> getActivity().finish());
        llTop = (LinearLayout) view.findViewById(R.id.ll_top);
        llCenter = (RelativeLayout) view.findViewById(R.id.ll_center);
        llLeft = (LinearLayout) view.findViewById(R.id.ll_left);
        llRight = (LinearLayout) view.findViewById(R.id.ll_right);
        llBottom = (LinearLayout) view.findViewById(R.id.ll_bottom);

        mViewMainTop = view.findViewById(R.id.view_main_top);
        mViewMainLeft = view.findViewById(R.id.view_main_left);
        mViewMainRight = view.findViewById(R.id.view_main_right);
        mViewMainDown = view.findViewById(R.id.view_main_down);
        imgPower = (ImageView) view.findViewById(R.id.img_bottom);
        imgRight = (ImageView) view.findViewById(R.id.img_right);
        tvTop = (TextView) view.findViewById(R.id.tv_top);
        tvBottom = (TextView) view.findViewById(R.id.tv_bottom);
        tvLeft = (TextView) view.findViewById(R.id.tv_left);
        tvRight = (TextView) view.findViewById(R.id.tv_right);
        tvCenter = (TextView) view.findViewById(R.id.tv_center);
        ivErrors = (ImageView) view.findViewById(R.id.iv_errors);
        tvMode = (TextView) view.findViewById(R.id.tv_mode);
        tvLine = (TextView) view.findViewById(R.id.tv_line);

        mViewMainTop = view.findViewById(R.id.view_main_top);
        mViewMainLeft = view.findViewById(R.id.view_main_left);
        mViewMainRight = view.findViewById(R.id.view_main_right);
        mViewMainDown = view.findViewById(R.id.view_main_down);

        errorsList.add(new ArrayList<>());
        errorsList.add(new ArrayList<>());
        errorsList.add(new ArrayList<>());
        errorsList.add(new ArrayList<>());
        errorsList.add(new ArrayList<>());
        errorsList.add(new ArrayList<>());

        EventBus.getDefault().register(this);

    }


    private int flag;
    /**
     * 初始化定时器
     */
    private void initTimeTask() {
        RxTimerUtil.interval(2000, new RxTimerUtil.IRxNext() {
            @Override
            public void doNext() {
                //获取当前连接的wifi id
                if (!TextUtils.isEmpty(getLocalIpAddress()) && getLocalIpAddress().contains("10.10.100")) {
                    //
                    tvLine.setVisibility(View.GONE);
                    tvMode.setVisibility(View.VISIBLE);
                    if(flag==1){
                        SocketUtils.connectSocket();
                        Log.e(TAG, "onResume: 开始连接");
                        flag = 1;
                    }
                } else {
                    Log.e(TAG, "doNext: 哈哈哈哈哈" );
                    flag =1;
                    SocketUtils.closeSocket();
                    tvLine.setVisibility(View.VISIBLE);
                    ivErrors.setVisibility(View.GONE);
                    tvMode.setVisibility(View.GONE);
                    tvBottom.setText(null);
                    tvCenter.setText(null);
                    tvTop.setText(null);
                    tvLeft.setText(null);
                    tvRight.setText(null);
                    setLineEnable();

                }

            }
        });

    }

    /**
     * 获取本机IP地址
     *
     * @return
     */
    public String getLocalIpAddress() {

        WifiManager wifiManager = (WifiManager) getmActivity().getApplicationContext().getSystemService(android.content.Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        int ipAddress = wifiInfo.getIpAddress();
        try {
            return InetAddress.getByName(String.format("%d.%d.%d.%d",
                    (ipAddress & 0xff), (ipAddress >> 8 & 0xff),
                    (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff))).toString();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public void onPause() {
        super.onPause();

    }
    @Override
    public void onResume() {
        super.onResume();

    }
    private boolean isQuery;
    @Override
    protected void initData() {
        getLoadingDialog().show();

        //连接socket 实时获取实时数据
        SocketUtils.connectSocket();
        Log.e(TAG, "onResume: 开始连接");
        //初始化定时器
        initTimeTask();
        isQuery = true;
        MainRxTimerUtil.cancel();
        MainRxTimerUtil.timer(16000, new MainRxTimerUtil.IRxNext() {
            @Override
            public void doNext() {
                if(isQuery){
                    getLoadingDialog().dismiss();
                    ToastUitl.showImageToastTips("Time timeout");
                }
            }
        });
    }
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        SocketUtils.closeSocket();
        EventBus.getDefault().unregister(this);
        if (rxBus != null) {
            rxBus.unSubscribe(this);
            rxBus = null;
        }
        SPUtil.clearData(DIVICE_SP);

    }
    private TextView btnBottomOne ;//= (TextView) holder.getView(R.id.btn_one);
    private TextView btnBottomTwo ;//= (TextView) holder.getView(R.id.btn_two);
    private TextView btnBottomThree ;//= (TextView) holder.getView(R.id.btn_three);
    private TextView btnBottomFour ;//= (TextView) holder.getView(R.id.btn_four);
    private TextView btnBottomFive ;//= (TextView) holder.getView(R.id.btn_five);
    private TextView btnBottomSix ;//= (TextView) holder.getView(R.id.btn_six);
    private TextView btnBottomCancel ;//= (TextView) holder.getView(R.id.btn_cancel);

    /**
     * 下部分电池
     */
    private void showBottomDialog() {
        NiceDialog.init()
                .setLayoutId(R.layout.dialog_native_bottom_select)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        dialog.setOutCancel(false);

                        btnBottomOne = (TextView) holder.getView(R.id.btn_one);
                        btnBottomTwo = (TextView) holder.getView(R.id.btn_two);
                        btnBottomThree = (TextView) holder.getView(R.id.btn_three);
                        btnBottomFour = (TextView) holder.getView(R.id.btn_four);
                        btnBottomFive = (TextView) holder.getView(R.id.btn_five);
                        btnBottomSix = (TextView) holder.getView(R.id.btn_six);
                        btnBottomCancel = (TextView) holder.getView(R.id.btn_cancel);


                        btnBottomOne.setText("Battery voltage：" + NumberUtils.forMatOneNumber(bottomOne * 0.1) + "V");
                        btnBottomTwo.setText("Battery current：" + NumberUtils.forMatOneNumber(bottomTwo * 0.1) + "A");
                        
                        btnBottomThree.setText("Battery power：" + bottomThree + "W");
                        btnBottomFour.setText("Remaining energy：" + bottomFour + "kWh");
                        btnBottomFive.setText("Remaining energy %：" + NumberUtils.forMatOneNumber(bottomFive * 0.1) + "%");
                        btnBottomSix.setText("Battery temperature：" + bottomSix + "℃");

                        holder.getView(R.id.rl_main).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                        holder.getView(R.id.ll_bottom).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {

                            }
                        });
                        btnBottomCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                dialog.dismiss();
                            }
                        });


                    }
                })
                .setOutCancel(true)
                .setShowBottom(true)
                .show(getActivity().getSupportFragmentManager());
    }
    //////上边电网
    private TextView btnTopOne ;//= (TextView) holder.getView(R.id.btn_one);
    private TextView btnTopTwo ;//= (TextView) holder.getView(R.id.btn_two);
    private TextView btnTopThree ;//= (TextView) holder.getView(R.id.btn_three);
    private TextView btnTopFour ;//= (TextView) holder.getView(R.id.btn_four);
    private TextView btnTopCancel ;//= (TextView) holder.getView(R.id.btn_cancel);
    /**
     * 上边电网
     */
    private void showTopsDialog() {
        NiceDialog.init()
                .setLayoutId(R.layout.dialog_native_tops_select)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        dialog.setOutCancel(false);

                        btnTopOne = (TextView) holder.getView(R.id.btn_one);
                        btnTopTwo = (TextView) holder.getView(R.id.btn_two);
                        btnTopThree = (TextView) holder.getView(R.id.btn_three);
                        btnTopFour = (TextView) holder.getView(R.id.btn_four);
                        btnTopCancel = (TextView) holder.getView(R.id.btn_cancel);

                        //
                        btnTopOne.setText("Grid voltage：" + NumberUtils.forMatOneNumber(rightOne * 0.1) + "V");
                        btnTopTwo.setText("Grid current：" + NumberUtils.forMatOneNumber(rightTwo * 0.1) + "A");
                        btnTopThree.setText("Grid power：" + rightThree + "W");
                        btnTopFour.setText("Grid frequency：" + NumberUtils.forMatNumber(rightFour * 0.01) + "HZ");
                        holder.getView(R.id.rl_main).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                        holder.getView(R.id.ll_bottom).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {

                            }
                        });

                        btnTopCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                dialog.dismiss();
                            }
                        });


                    }
                })


                .setShowBottom(true)
                .setOutCancel(true)
                .show(getActivity().getSupportFragmentManager());

    }
    private   TextView btnCenterOne;
    /**
     * 中间逆变器
     */
    private void showCenterDialog() {
        NiceDialog.init()
                .setLayoutId(R.layout.dialog_native_center_select)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        dialog.setOutCancel(false);

                        btnCenterOne = (TextView) holder.getView(R.id.btn_one);
                        TextView btnTwo = (TextView) holder.getView(R.id.btn_two);
                        TextView btnCancel = (TextView) holder.getView(R.id.btn_cancel);
                        btnCenterOne.setText("Inverter power：" + centerOne + "W");
                        holder.getView(R.id.rl_main).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                        holder.getView(R.id.ll_bottom).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {

                            }
                        });
                        btnCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                dialog.dismiss();
                            }
                        });


                    }
                })
                .setOutCancel(true)
                .setShowBottom(true)
                .show(getActivity().getSupportFragmentManager());
    }

     private TextView btnRightOne ;//= (TextView) holder.getView(R.id.btn_one);
     private TextView btnRightTwo ;//= (TextView) holder.getView(R.id.btn_two);
     private TextView btnRightThree;// = (TextView) holder.getView(R.id.btn_three);
     private TextView btnRightFour ;//= (TextView) holder.getView(R.id.btn_four);
     private TextView btnRightCancel ;//= (TextView) holder.getView(R.id.btn_cancel);


    /**
     * 右边EPS 附载
     */
    private void showRightsDialog() {
        NiceDialog.init()
                .setLayoutId(R.layout.dialog_native_rights_select)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        dialog.setOutCancel(false);

                        btnRightOne = (TextView) holder.getView(R.id.btn_one);
                        btnRightTwo = (TextView) holder.getView(R.id.btn_two);
                        btnRightThree = (TextView) holder.getView(R.id.btn_three);
                        btnRightFour = (TextView) holder.getView(R.id.btn_four);
                        btnRightCancel = (TextView) holder.getView(R.id.btn_cancel);

                        btnRightOne.setText("EPS output voltage：" + NumberUtils.forMatOneNumber(leftOne * 0.1) + "V");
                        btnRightTwo.setText("EPS output current：" + NumberUtils.forMatOneNumber(leftTwo * 0.1) + "A");
                        btnRightThree.setText("EPS output frequency：" + NumberUtils.forMatNumber(leftThree * 0.01) + "HZ");
                        btnRightFour.setText("EPS output power：" + leftFour + "W");

                        holder.getView(R.id.rl_main).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                        holder.getView(R.id.ll_bottom).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {

                            }
                        });
                        btnRightCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                dialog.dismiss();
                            }
                        });


                    }
                })
                .setOutCancel(true)
                .setShowBottom(true)
                .show(getActivity().getSupportFragmentManager());
    }

    private TextView btnLeftOne ;//= (TextView) holder.getView(R.id.btn_one);
    private TextView btnLeftTwo ;//= (TextView) holder.getView(R.id.btn_two);
    private TextView btnLeftThree ;//= (TextView) holder.getView(R.id.btn_three);
    private TextView btnLeftFour ;//= (TextView) holder.getView(R.id.btn_four);
    private TextView btnLeftFive ;//= (TextView) holder.getView(R.id.btn_five);
    private TextView btnLeftSix ;//= (TextView) holder.getView(R.id.btn_six);
    private TextView btnLeftCancel;// = (TextView) holder.getView(R.id.btn_cancel);

    /**
     * 左边
     */
    private void showLeftsDialog() {
        NiceDialog.init()
                .setLayoutId(R.layout.dialog_native_lefts_select)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        dialog.setOutCancel(false);

                        btnLeftOne = (TextView) holder.getView(R.id.btn_one);
                        btnLeftTwo = (TextView) holder.getView(R.id.btn_two);
                        btnLeftThree = (TextView) holder.getView(R.id.btn_three);
                        btnLeftFour = (TextView) holder.getView(R.id.btn_four);
                        btnLeftFive = (TextView) holder.getView(R.id.btn_five);
                        btnLeftSix = (TextView) holder.getView(R.id.btn_six);
                        btnLeftCancel = (TextView) holder.getView(R.id.btn_cancel);

                        btnLeftOne.setText("PV #1 voltage：" + NumberUtils.forMatOneNumber(topOne * 0.1) + "V");
                        btnLeftTwo.setText("PV #1 current：" + NumberUtils.forMatOneNumber(topTwo * 0.1) + "A");
                        btnLeftThree.setText("PV #1 power：" + value4 + "W");
                        btnLeftFour.setText("PV #2 voltage：" + NumberUtils.forMatOneNumber(topFour * 0.1) + "V");
                        btnLeftFive.setText("PV #2 current：" + NumberUtils.forMatOneNumber(topFive * 0.1) + "A");
                        btnLeftSix.setText("PV #2 power：" + topSix + "W");
                        holder.getView(R.id.rl_main).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                        holder.getView(R.id.ll_bottom).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {

                            }
                        });

                        btnLeftCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                dialog.dismiss();
                            }
                        });


                    }
                })
                .setOutCancel(true)
                .setShowBottom(true)
                .show(getActivity().getSupportFragmentManager());

    }

    @Override
    protected void initListener() {
        ivErrors.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showErrorsDialog();
            }
        });
        llLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                //左部分光伏
                showLeftsDialog();

            }
        });
        llRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                //右边EPS 附载
                showRightsDialog();
            }
        });

        llTop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //上边电网
                showTopsDialog();

            }
        });

        llBottom.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //下部分电池
                showBottomDialog();
            }
        });

        llCenter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //中间逆变器
                showCenterDialog();
            }
        });
    }

    /**
     * 故障对话框
     */
    private void showErrorsDialog() {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < errorsList.size(); i++) {

            if (EmptyUtils.isNotEmpty(errorsList.get(i))) {
                for (int j = 0; j < errorsList.get(i).size(); j++) {
                    list.add(errorsList.get(i).get(j));
                }
            }


        }
        NiceDialog.init()
                .setLayoutId(R.layout.dialog_native_errors)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        dialog.setOutCancel(false);


                        RecyclerView recyclerview = (RecyclerView) holder.getView(R.id.recyclerview);
                        TextView btnCancel = (TextView) holder.getView(R.id.btn_cancel);
                        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getmActivity());
                        recyclerview.setLayoutManager(linearLayoutManager);
                        ErrorsListAdapter errorsListAdapter = new ErrorsListAdapter(list, getmActivity());
                        recyclerview.setAdapter(errorsListAdapter);

                        RelativeLayout llMain =  holder.getView(R.id.ll_main);;




                        llMain.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                        holder.getView(R.id.recyclerview).setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });

                        btnCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                dialog.dismiss();
                            }
                        });


                    }
                })
                .setOutCancel(true)
                .setShowBottom(true)
                .show(getActivity().getSupportFragmentManager());


    }




    //光伏
    private int topOne;
    private int topTwo;
    private int topThree;
    private int topFour;
    private int topFive;
    private int topSix;

    //EPS
    private int leftOne;
    private int leftTwo;
    private int leftThree;
    private int leftFour;

    //逆变器
    //EPS
    private int centerOne;
    private int centerTwo;

    //电网
    private int rightOne;
    private int rightTwo;
    private int rightThree;
    private int rightFour;

    //电池
    private int bottomOne;
    private int bottomTwo;
    private int bottomThree;
    private int bottomFour;
    private int bottomFive;
    private int bottomSix;
    private int value4;

    //熊浪添加RxBus工具类，页面销毁时需要取消注册，否则会有内存泄漏
    private RxBus rxBus;
    private List<List<String>> errorsList = new ArrayList<>();

    //

    private List<String> BCMU故障告警信息List = new ArrayList<>();
    private List<String> BSMU故障告警信息List = new ArrayList<>();
    private List<String> PCS故障告警信息List = new ArrayList<>();
    private List<String> DCDC故障告警信息List = new ArrayList<>();
    private List<String> EMS故障告警信息List = new ArrayList<>();



    /**
     * 初始化本地相关的RxBus
     */

    //BSMU告警
    private List<String> 电池堆客户告警信息A = new ArrayList<>();
    private List<String> 电池堆客户告警信息B = new ArrayList<>();
    private List<String> 电池堆内部告警信息A = new ArrayList<>();
    private List<String> 电池堆内部告警信息B = new ArrayList<>();

    private List<String> 电池堆内部告警信息C = new ArrayList<>();
    private List<String> 电池堆内部告警信息D = new ArrayList<>();
    private List<String> 电池堆客户故障信息A = new ArrayList<>();
    private List<String> 电池堆客户故障信息B = new ArrayList<>();

    private List<String> 电池堆内部故障信息A = new ArrayList<>();
    private List<String> 电池堆内部故障信息B = new ArrayList<>();
    private List<String> 电池堆内部故障信息C = new ArrayList<>();
    private List<String> 电池堆内部故障信息D = new ArrayList<>();


    //BMS告警
    private List<String> BCMU客户告警信息1 = new ArrayList<>();
    private List<String> BCMU客户告警信息2 = new ArrayList<>();
    private List<String> BCMU内部告警信息1 = new ArrayList<>();
    private List<String> BCMU内部告警信息2 = new ArrayList<>();

    private List<String> BCMU客户故障信息1 = new ArrayList<>();
    private List<String> BCMU客户故障信息2 = new ArrayList<>();
    private List<String> BCMU内部故障信息1 = new ArrayList<>();
    private List<String> BCMU内部故障信息2 = new ArrayList<>();


    //EMS告警
    private List<String> EMS客户告警信息0 = new ArrayList<>();
    private List<String> EMS客户告警信息1 = new ArrayList<>();
    private List<String> EMS客户告警信息2 = new ArrayList<>();
    private List<String> EMS客户告警信息3 = new ArrayList<>();

    private List<String> EMS客户告警信息4 = new ArrayList<>();
    private List<String> EMS客户告警信息5 = new ArrayList<>();
    private List<String> EMS客户故障信息0 = new ArrayList<>();
    private List<String> EMS客户故障信息1 = new ArrayList<>();
    private List<String> EMS客户故障信息2 = new ArrayList<>();
    private List<String> EMS客户故障信息3 = new ArrayList<>();
    private List<String> EMS客户故障信息4 = new ArrayList<>();
    private List<String> EMS客户故障信息5 = new ArrayList<>();



    //DCDC告警
    private List<String> DCDC客户告警信息0 = new ArrayList<>();
    private List<String> DCDC客户告警信息1 = new ArrayList<>();
    private List<String> DCDC客户告警信息2 = new ArrayList<>();
    private List<String> DCDC客户告警信息3 = new ArrayList<>();
    private List<String> DCDC客户告警信息4 = new ArrayList<>();
    private List<String> DCDC客户告警信息5 = new ArrayList<>();
    // DCDC故障
    private List<String> DCDC客户故障信息0 = new ArrayList<>();
    private List<String> DCDC客户故障信息1 = new ArrayList<>();
    private List<String> DCDC客户故障信息2 = new ArrayList<>();
    private List<String> DCDC客户故障信息3 = new ArrayList<>();
    private List<String> DCDC客户故障信息4 = new ArrayList<>();
    private List<String> DCDC客户故障信息5 = new ArrayList<>();


    //PCS告警
    private List<String> PCS客户告警信息0 = new ArrayList<>();
    private List<String> PCS客户告警信息1 = new ArrayList<>();
    private List<String> PCS客户告警信息2 = new ArrayList<>();
    private List<String> PCS客户告警信息3 = new ArrayList<>();
    private List<String> PCS客户告警信息4 = new ArrayList<>();
    private List<String> PCS客户告警信息5 = new ArrayList<>();
    // PCS故障
    private List<String> PCS客户故障信息0 = new ArrayList<>();
    private List<String> PCS客户故障信息1 = new ArrayList<>();
    private List<String> PCS客户故障信息2 = new ArrayList<>();
    private List<String> PCS客户故障信息3 = new ArrayList<>();
    private List<String> PCS客户故障信息4 = new ArrayList<>();
    private List<String> PCS客户故障信息5 = new ArrayList<>();



    private String[] modes = new String[]{"Power on", "Standby", "Self-consumption ", "Peak shifting", "Backup power", "Manual mode", "Fault", "Testing mode"};


    /**
     * BSMU故障告警信息
     */

    private String[] BSMUAS = new String[]{"Junction cabinet separator switch off", "Battery cluster protection", "Battery clusters voltage gap overlimit", " Battery cluster charging power overlimit",
            "Battery cluster discharging power overlimit", "Battery cluster startup failed", "", " ", "", " ",
            "", " ", "  ", " ", " ", " "};


    private String[] BSMUBS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] BSMUCS = new String[]{"BSMU configuration failed", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] BSMUDS = new String[]{"1# Battery pack enable is not running", "2# Battery pack enable is not running", "3# Battery pack enable is not running", "4# Battery pack enable is not running",
            "5# Battery pack enable is not running", "6# Battery pack enable is not running", "7# Battery pack enable is not running", "8# Battery pack enable is not running", "9# Battery pack enable is not running", "10# Battery pack enable is not running",
            "11# Battery pack enable is not running", "12# Battery pack enable is not running", "13# Battery pack enable is not running", "14# Battery pack enable is not running", "15# Battery pack enable is not running", "16# Battery pack enable is not running"};




    private String[] BSMUES = new String[]{"1# Battery failed and isolated", " 2# Battery failed and isolated", "3# Battery failed and isolated", "4# Battery failed and isolated",
            "5# Battery failed and isolated", "6# Battery failed and isolate", "7# Battery failed and isolate", "8# Battery failed and isolate", "9# Battery failed and isolate", "10# Battery failed and isolate",
            "11# Battery failed and isolate", "12# Battery failed and isolate", "13# Battery failed and isolate", "14# Battery failed and isolate", "15# Battery failed and isolate", "16# Battery failed and isolate"};


    private String[] BSMUFS = new String[]{"1# Battery alarmed and isolated", "2# Battery alarmed and isolated", "3# Battery alarmed and isolated", "4# Battery alarmed and isolated",
            "5# Battery alarmed and isolated", "6# Battery alarmed and isolated", "7# Battery alarmed and isolated", "8# Battery alarmed and isolated", "9# Battery alarmed and isolated", "10# Battery alarmed and isolated",
            "11# Battery alarmed and isolated", "12# Battery alarmed and isolated", "13# Battery alarmed and isolated", "14# Battery alarmed and isolated", "15# Battery alarmed and isolated", "16# Battery alarmed and isolated"};




    private String[] BSMUGS = new String[]{"No batteries within the Cluster", "Battery cluster leaks", "Battery cluster starup failed", "Battery cluster stop filed",
            "Battery cluster controlling contatcor failed", "Battery cluster detecting contactor error", "Battery cluster failed to communicate with UCC CAN", "Battery cluster detecting power cable offline", "", "",
            "", "", "", "", "", ""};

    private String[] BSMUHS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] BSMUIS = new String[]{"Battery cluster badly leaks ", "", "", "",
            "", "", "", "", "", "",
            " ", "", "", "", "", ""};


    private String[] BSMUJS = new String[]{"1# Battery cluster contactor control faile", "2#  Battery cluster contactor control failed", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", "2# Battery cluster contactor abnormale behavior "};

    private String[] BSMUKS = new String[]{"1# Battery cluster contactor abnormale behavior detected", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] BSMULS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    /**
     * PCS故障告警信息
     */

    private String[] PCSAS = new String[]{"AC over-temperature alarm", "AC overload alarm", "PCS_Alarm_Res2", " PCS_Alarm_Res3",
            "PCS_Alarm_Res4", "PCS_Alarm_Res5", "PCS_Alarm_Res6", " PCS_Alarm_Res7", "PCS_Alarm_Res8", " PCS_Alarm_Res9",
            "PCS_Alarm_Res10", " PCS_Alarm_Res11", " PCS_Alarm_Res12 ", " PCS_Alarm_Res13", " PCS_Alarm_Res14", " PCS_Alarm_Res15"};


    private String[] PCSBS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] PCSCS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] PCSDS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] PCSES = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", " ", "", "", ""};


    private String[] PCSFS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] PCSGS = new String[]{"PV1 low pressure fault", "PV2 low pressure fault", "PV1 high-voltage faults", "PV2 high-voltage faults",
            "PV1 overcurrent fault", "PV2 overcurrent fault", "PV1 insulation impedance fault", "PV2 insulation impedance fault", "grid voltage fault", "power frequency fault",
            "AC_BUS boot failure", "AC_BUS low pressure fault", "AC_BUS short circuit", "AC_BUS high-voltage faults", "fault low voltage inverter", "high voltage inverter failure"};

    private String[] PCSHS = new String[]{"Inverter short-circuit fault", "inverter failed to start", "overload fault", "AC_NTC missed fault",
            "DC communication failure", "AC control board EEPROM read error", "Inverter overcurrent fault", "CAN communication failure ", "low battery SOC", "leakage current detection fault",
            "persistent leakage current detector failure", "abrupt fault leakage current", "abrupt fault current inverter", "grid overcurrent fault", " mutations grid current fault", "10min average voltage overvoltage fault"};


    private String[] PCSIS = new String[]{"islanding detection failures", "Dead fault relay sticky", "peaks of the electrical overvoltage fault", "PV1 overpower protection",
            "PV2 overpower protection", "AC overtemperature fault", "quick fault detection voltage inverter", "PV parallel Voltage malfunction", "PCS_Fault_Res40", "PCS_Fault_Res41",
            " PCS_Fault_Res42", "PCS_Fault_Res43", "PCS_Fault_Res44", "PCS_Fault_Res45", "PCS_Fault_Res46", "PCS_Fault_Res47"};


    private String[] PCSJS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] PCSKS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] PCSLS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    /**
     * DCDC故障告警信息
     */

    private String[] DCDCAS = new String[]{"over-temperature alarm", "DCDC_Alarm_Res1", "DCDC_Alarm_Res2", "CDC_Alarm_Res3",
            "CDC_Alarm_Res4", "CDC_Alarm_Res5", "CDC_Alarm_Res6", "CDC_Alarm_Res7", "CDC_Alarm_Res8", "CDC_Alarm_Res9",
            "CDC_Alarm_Res10", "CDC_Alarm_Res11", "CDC_Alarm_Res12 ", "CDC_Alarm_Res13", "CDC_Alarm_Res14", "CDC_Alarm_Res15"};


    private String[] DCDCBS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] DCDCCS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] DCDCDS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] DCDCES = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", " ", "", "", ""};


    private String[] DCDCFS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] DCDCGS = new String[]{"DC overtemperature fault", "DC_NTC missed fault", "DC power loss fault", "DC_BUS low pressure fault ",
            "DC_BUS overvoltage fault", "DC_BUS short circuit", "DC startup timeout", "Low battery", "cell overvoltage", "overcurrent battery",
            "communication failure with AC", "battery reverse", " battery missed", "DCDC_Fault_Res13", "DCDC_Fault_Res14", "DCDC_Fault_Res15"};

    private String[] DCDCHS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] DCDCIS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", " ", "", "", ""};


    private String[] DCDCJS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] DCDCKS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] DCDCLS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    /**
     * BCMU故障告警信息
     */

    private String[] BCMUAS = new String[]{"BAT charging overcurrent", "BAT discharge overcurrent", " BAT cell overvoltage", "BAT voltage  low voltage",
            "BAT charging over temperature", "BAT charging low  temperature", "BAT discharge over temperature", " BAT discharge low temperature", " BAT isolator switch off", "BAT switch1 disconnect",
            "BAT switch2 disconnect", "BAT high-voltage sampling abnormality", "BAT high-voltage temperature sampling abnormality ", "BAT leakage detection failure", "BAT pre-charge over-temperature", "BAT Contactor overtemperature"};


    private String[] BCMUBS = new String[]{"battery fuse overtemperature", "battery start failed", "battery pack is fully off", "battery self protection",
            "battery CAN communication with the high-voltage break", "BCMU_A_Reserve21", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] BCMUCS = new String[]{"battery charging overcurrent", "battery discharge overcurrent", "battery charging  severe overcurrent", "battery discharge severe overcurrent",
            "battery severe high voltage", "battery severe low-voltage", "battery charging temperature serious low", "battery discharge temperature serious low", "battery voltage drop consistency", " battery temperature field maldistribution",
            "battery capacity fade exception", "battery remaining  capacity is low", "BCMU_A_Reserve44", "BCMU_A_Reserve45", "BCMU_A_Reserve46", "BCMU_A_Reserve47"};


    private String[] BCMUDS = new String[]{"BMU battery equalization circuit abnormality detecting Press ", "BMU balance control circuit of the battery pack abnormality", "BCMU_A_Reserve50", "BCMU_A_Reserve51",
            "BCMU_A_Reserve52", "BCMU_A_Reserve53", "repeating node BMU battery", "Software version BMU battery abnormality", "single high voltage battery warning", "low battery cell voltage warning",
            "", "", "", "", "", ""};


    private String[] BCMUES = new String[]{"sampling circuit BMU battery abnormality", "battery BMU sampling line broken", "BMU and the battery pack CAN communication disconnection", "battery CAN external communication disconnection",
            "battery current sampling circuit abnormality", "the battery pack to feed back circuit abnormality detecting", "battery fuse blowing", "smoke sensor battery alarm", "battery drain", "charging the battery pack severe overtemperature protection",
            "severe overtemperature battery discharge protection", "battery cell failure", "pack negative contacts abnormality ", "main contactor battery abnormality", "pre-charge the battery pack contacts abnormality", "battery charging overcurrent instantaneous"};


    private String[] BCMUFS = new String[]{"battery discharge short-circuit overcurrent protection", "BCMU_F_Reserve17", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] BCMUGS = new String[]{"severe battery drain", "back pack negative contactor abnormality detecting circuit", "battery back main contact abnormality detecting circuit", "battery back precharge contactor abnormality detecting circuit",
            "BCMU_F_Reserve36", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] BCMUHS = new String[]{"sampling circuit BMU battery abnormality", "BMU battery voltage sampling line broken", "battery temperature sampling line broken BMU", "BCMU_F_Reserve51",
            "BCMU_F_Reserve52", "BCMU_F_Reserve53", "BCMU_F_Reserve54", "BCMU_F_Reserve55", "disconnection of the battery pack BMU CAN", "BCMU_F_Reserve57",
            "", "", "", "", "", ""};


    /**
     * EMS告警故障信息
     */

    private String[] EMSAS = new String[]{"the inverter powers off for faults", "DCDC powers off for faults", "Low battery alarm", "EMS_Alarm_Res3",
            "EMS_Alarm_Res4", "EMS_Alarm_Res5", "EMS_Alarm_Res6", "EMS_Alarm_Res7", "EMS_Alarm_Res8", "EMS_Alarm_Res9",
            "EMS_Alarm_Res10", "EMS_Alarm_Res11", "", "", "", ""};


    private String[] EMSBS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] EMSCS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] EMSDS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};


    private String[] EMSES = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", " ", "", "", ""};


    private String[] EMSFS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] EMSGS = new String[]{"PCS configuration timeout", "PCS configuration fails", "Timeout of control information delivery", "Failure of control information delivery",
            "Operating mode of PCS and EMS is inconsistent", "Power-on query failed", "System is locked out on repeated errors", "Communication failure with BMS", "Communication failure with meter", "Communication failure with PCS",
            "EEPROM faults", "PCS switch fails", "DRM test fails", "EMS_Fault_Res13", "EMS_Fault_Res14", "EMS_Fault_Res15"};

    private String[] EMSHS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] EMSIS = new String[]{"EEPROM faults", "EMS_Fault_Res33", "EMS_Fault_Res34", "EMS_Fault_Res35",
            "EMS_Fault_Res36", "EMS_Fault_Res37", "EMS_Fault_Res38", "EMS_Fault_Res39", "", "",
            "", "", "", "", "", ""};

    private String[] EMSJS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] EMSKS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};

    private String[] EMSLS = new String[]{"", "", "", "",
            "", "", "", "", "", "",
            "", "", "", "", "", ""};
    ////




    protected void setLineEnable() {
        mViewMainTop.setStatus(2);
        mViewMainLeft.setStatus(2);
        mViewMainRight.setStatus(1);
        mViewMainDown.setStatus(2);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        SocketUtils.closeSocket();
        RxTimerUtil.cancel();
        if (rxBus != null) {
            rxBus.unSubscribe(this);
            rxBus = null;
        }

    }

    /**
     * //监听外来是否要去成功的界面
     *
     * @param event
     */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(MessageEvent event) {
        /* Do something */
        if (EmptyUtils.isNotEmpty(event)
                && EmptyUtils.isNotEmpty(event.getSendMessage())

        ) {

            initSenMessage(event.getSendMessage());
        }
    }

    private void initSenMessage(RxBusBean.SendMessage sendMessage) {

        Log.e(TAG, "fragment接受到的数据: " + sendMessage.readContent.toString());
        //车辆登入
        if (sendMessage != null && sendMessage.readContent[2] == SocketConfig.VEHICLE_ACCESS)
        {

            Log.e("车辆登入", "我接收到了的所有数据(已过滤传输规则中其他数据):" + Arrays.toString(sendMessage.info) + ",总数据长度:" + sendMessage.info.length);
            Log.e("车辆登入", "我接收到了来自车辆登入的接口数据");
            Log.e("车辆登入", "前六位是年月日时分秒:" + DataUtils.HexToInt(sendMessage.info[0]) + "年" + DataUtils.HexToInt(sendMessage.info[1]) + "月" + DataUtils.HexToInt(sendMessage.info[2]) + "日" + DataUtils.HexToInt(sendMessage.info[3]) + "时" + DataUtils.HexToInt(sendMessage.info[4]) + "分" + DataUtils.HexToInt(sendMessage.info[5]) + "秒");
            Log.e("车辆登入", "第七位和第八位是登入流水号:" + DataUtils.HexToInt(sendMessage.info[6]) + ":" + DataUtils.HexToInt(sendMessage.info[7]));
            StringBuilder stringBuffer = new StringBuilder("");
            for (int i = 0; i < 20; i++) {
                stringBuffer.append(sendMessage.info[8 + i]);
            }
            Log.e("车辆登入", "ICCID:" + stringBuffer.toString());
            Log.e("车辆登入", "动力蓄电池总数:" + sendMessage.info[28]);
            StringBuilder stringBuffer2 = new StringBuilder("");
            for (int i = 29; i < sendMessage.info.length; i++) {
                stringBuffer2.append(sendMessage.info[i]);
            }
            Log.e("车辆登入", "电池编码:" + stringBuffer2.toString());

            String diviceId =SPUtil.getData(DIVICE_SP, Constant.SP_VALUE.DEVICE_ID,String.class,null);
            if(TextUtils.isEmpty(diviceId)){
                SPUtil.putData(DIVICE_SP, Constant.SP_VALUE.DEVICE_ID, SocketUtils.getStringBuilder(sendMessage.info));
            }


            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            Log.e("车辆登入", "发送的16进制指令: " + DataUtils.hexBytesToString(SocketConfig.getSetting()));
                            SocketUtils.sendSerialPort(SocketConfig.settingVehicleAccess(sendMessage.readContent));


                        }
                    }).start();

                }
            }, 10);


        }

        if (sendMessage != null && sendMessage.readContent[2] == SocketConfig.HEARTBEAT)
        {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    new Thread(new Runnable() {
                        @Override
                        public void run() {

                            Log.e("心跳", "回复心跳 发送的16进制指令: " + DataUtils.hexBytesToString(SocketConfig.getHeart()));
                            SocketUtils.sendSerialPort(SocketConfig.getHeart());


                        }
                    }).start();

                }
            }, 10);




        }

        //   ***实时信息上报**
        if (sendMessage != null && sendMessage.readContent[2] == SocketConfig.REAL_TIME) {
            isQuery = false;
            getLoadingDialog().dismiss();
            Log.e(TAG, "实时信息----------------: " );

//            MessageEvent messageEvent = new MessageEvent();
//            messageEvent.setSendMessage(sendMessage);
//            EventBus.getDefault().post(messageEvent);



            Log.e("实时信息", "我接收到了实时信息的所有数据(已过滤传输规则中其他数据):" + Arrays.toString(sendMessage.info));
            Log.e("实时信息", "前六位是年月日时分秒:" + DataUtils.HexToInt(sendMessage.info[0]) + "年" + DataUtils.HexToInt(sendMessage.info[1]) + "月" + DataUtils.HexToInt(sendMessage.info[2]) + "日" + DataUtils.HexToInt(sendMessage.info[3]) + "时" + DataUtils.HexToInt(sendMessage.info[4]) + "分" + DataUtils.HexToInt(sendMessage.info[5]) + "秒");
            if (sendMessage.info.length > 7) {
                int length = DataUtils.HexToInt(sendMessage.info[8] + sendMessage.info[7]);//实时信息的数据长度
                if (DataUtils.HexToInt(sendMessage.info[6]) == 0x90) { //BSMU信息上传(0x90)
                    Log.e("实时信息0x90", ":" + Arrays.toString(sendMessage.info));
                    Log.e("实时信息0x90", "BSMU信息上传(0x90),对应数据长度:" + length + ",总数据长度:" + sendMessage.info.length);

                    //  BSMU告警 BSMU故障
                    //电池堆客户告警信息A
                    int BSMUA = Integer.parseInt(sendMessage.info[21] + sendMessage.info[20], 16);
                    //电池堆客户告警信息B
                    int BSMUB = Integer.parseInt(sendMessage.info[23] + sendMessage.info[22], 16);
                    //电池堆内部告警信息A
                    int BSMUC = Integer.parseInt(sendMessage.info[25] + sendMessage.info[24], 16);
                    //电池堆内部告警信息B
                    int BSMUD = Integer.parseInt(sendMessage.info[27] + sendMessage.info[26], 16);
                    //电池堆内部告警信息C
                    int BSMUE = Integer.parseInt(sendMessage.info[29] + sendMessage.info[28], 16);
                    //电池堆内部告警信息D
                    int BSMUF = Integer.parseInt(sendMessage.info[31] + sendMessage.info[30], 16);

                    //电池堆客户故障信息A
                    int BSMUG = Integer.parseInt(sendMessage.info[33] + sendMessage.info[32], 16);
                    //电池堆客户故障信息B
                    int BSMUH = Integer.parseInt(sendMessage.info[35] + sendMessage.info[34], 16);
                    //电池堆内部故障信息A
                    int BSMUI = Integer.parseInt(sendMessage.info[37] + sendMessage.info[36], 16);
                    //电池堆内部故障信息B
                    int BSMUJ = Integer.parseInt(sendMessage.info[39] + sendMessage.info[38], 16);
                    //电池堆内部故障信息C
                    int BSMUK = Integer.parseInt(sendMessage.info[41] + sendMessage.info[40], 16);
                    //电池堆内部故障信息D
                    int BSMUL = Integer.parseInt(sendMessage.info[43] + sendMessage.info[42], 16);


                    电池堆客户告警信息A.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUA >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUAS[z])) {
                                电池堆客户告警信息A.add(BSMUAS[z]);
                            }

                        }
                    }

                    电池堆客户告警信息B.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUB >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUBS[z])) {
                                电池堆客户告警信息B.add(BSMUBS[z]);
                            }

                        }
                    }

                    电池堆内部告警信息A.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUC >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUCS[z])) {
                                电池堆内部告警信息A.add(BSMUCS[z]);
                            }

                        }
                    }

                    电池堆内部告警信息B.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUD >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUDS[z])) {
                                电池堆内部告警信息B.add(BSMUDS[z]);
                            }

                        }
                    }


                    电池堆内部告警信息C.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUE >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUES[z])) {
                                电池堆内部告警信息C.add(BSMUES[z]);
                            }

                        }
                    }

                    电池堆内部告警信息D.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUF >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUFS[z])) {
                                电池堆内部告警信息D.add(BSMUFS[z]);
                            }

                        }
                    }


                    电池堆客户故障信息A.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUG >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUGS[z])) {
                                电池堆客户故障信息A.add(BSMUGS[z]);
                            }

                        }
                    }


                    电池堆客户故障信息B.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUH >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUHS[z])) {
                                电池堆客户故障信息B.add(BSMUHS[z]);
                            }

                        }
                    }


                    电池堆内部故障信息A.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUI >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUIS[z])) {
                                电池堆内部故障信息A.add(BSMUIS[z]);
                            }

                        }
                    }

                    电池堆内部故障信息B.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUJ >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUJS[z])) {
                                电池堆内部故障信息B.add(BSMUJS[z]);
                            }

                        }
                    }

                    电池堆内部故障信息C.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUK >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMUKS[z])) {
                                电池堆内部故障信息C.add(BSMUKS[z]);
                            }

                        }
                    }


                    电池堆内部故障信息D.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BSMUL >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BSMULS[z])) {
                                电池堆内部故障信息D.add(BSMULS[z]);
                            }

                        }
                    }
                    BSMU故障告警信息List.clear();
                    //BSMU
                    if (EmptyUtils.isNotEmpty(电池堆客户告警信息A)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆客户告警信息A);;
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆客户告警信息B)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆客户告警信息B);
                        BSMU故障告警信息List.add(a);
                    }
                    if (EmptyUtils.isNotEmpty(电池堆内部告警信息A)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆内部告警信息A);
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆内部告警信息B)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆内部告警信息B);
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆内部告警信息C)) {
                        String a = "" +StringUtils.Java7ListToString(电池堆内部告警信息C);
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆内部告警信息D)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆内部告警信息D);
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆客户故障信息A)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆客户故障信息A);
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆客户故障信息B)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆客户故障信息B);
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆内部故障信息A)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆内部故障信息A);
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆内部故障信息B)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆内部故障信息B);
                        BSMU故障告警信息List.add(a);
                    }
                    if (EmptyUtils.isNotEmpty(电池堆内部故障信息C)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆内部故障信息C);
                        BSMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(电池堆内部故障信息D)) {
                        String a = "" + StringUtils.Java7ListToString(电池堆内部故障信息D);
                        BSMU故障告警信息List.add(a);
                    }

                    errorsList.set(1, BSMU故障告警信息List);



                    if (EmptyUtils.isNotEmpty(errorsList)) {
                        if(EmptyUtils.isNotEmpty(errorsList.get(0))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(1))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(2))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(3))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(4))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }


                    } else {
                        ivErrors.setVisibility(View.GONE);
                    }


                } else if (DataUtils.HexToInt(sendMessage.info[6]) == 0x91) {//BCMU信息上传(0x91)
                    int value = DataUtils.HexToInt(sendMessage.info[39] + sendMessage.info[38]);
                    //下边的数据
                    tvBottom.setText(value + "W");

                    if (value > 0) {// 下边   Bat 大于零向上 等于零灰色 小于零向下
                        mViewMainDown.setStatus(0);
                    } else if (value == 0) {
                        mViewMainDown.setStatus(2);
                    } else {
                        mViewMainDown.setStatus(1);
                    }

                    Log.e("实时信息0x91", ":" + Arrays.toString(sendMessage.info));
                    Log.e("实时信息0x91", "BCMU信息上传(0x91),对应数据长度:" + length + ",总数据长度:" + sendMessage.info.length);
                    //电池功率 （BCMU电池组1运行功率 1W(负号表示充电)  ）
                    Log.e("实时信息", "XXXX电池功率（BCMU电池组1运行功率）=" + DataUtils.HexToInt(sendMessage.info[39] + sendMessage.info[38]));
                    //电池电压(电池组1总电压 U16 0.1V)
                    Log.e("实时信息", "XXXX电池电压（电池组1总电压）=" + DataUtils.HexToInt(sendMessage.info[35] + sendMessage.info[34]));
                    //电池电流(电池组1总电流,S16 0.1A(负号表示充电))
                    Log.e("实时信息", "XXXX电池电流（电池组1总电流）=" + DataUtils.HexToInt(sendMessage.info[37] + sendMessage.info[36]));
                    //电池功率
                    //
                    //剩余电量(电池组1剩余电能,1WH)
                    Log.e("实时信息", "XXXX剩余电量（电池组1剩余电能）=" + DataUtils.HexToInt(sendMessage.info[112] + sendMessage.info[111]));
                    //总电量(电池组1额定容量，1WH)
                    Log.e("实时信息", "XXXX总电量（电池组1额定容量）=" + DataUtils.HexToInt(sendMessage.info[110] + sendMessage.info[119]));

                    bottomFive = DataUtils.HexToInt(sendMessage.info[41] + sendMessage.info[40]);
                    //电池温度(电池组平均温度 S16  1℃)
                    Log.e("实时信息", "XXXX电池温度（电池组平均温度）=" + DataUtils.HexToInt(sendMessage.info[131] + sendMessage.info[130]));
                    //电池
                    bottomOne = DataUtils.HexToInt(sendMessage.info[35] + sendMessage.info[34]);
                    //
                    bottomTwo = DataUtils.HexToInt(sendMessage.info[37] + sendMessage.info[36]);
                    bottomThree = DataUtils.HexToInt(sendMessage.info[39] + sendMessage.info[38]);
                    bottomFour = DataUtils.HexToInt(sendMessage.info[79] + sendMessage.info[78]);
                    bottomSix = DataUtils.HexToInt(sendMessage.info[131] + sendMessage.info[130]);
                    if(btnBottomOne!=null){
                        btnBottomOne.setText("Battery voltage：" + NumberUtils.forMatOneNumber(bottomOne * 0.1) + "V");
                    }
                    if(btnBottomTwo!=null){
                        btnBottomTwo.setText("Battery current：" + NumberUtils.forMatOneNumber(bottomTwo * 0.1) + "A");
                    }

                    if(btnBottomThree!=null){
                        btnBottomThree.setText("Battery power：" + bottomThree + "W");
                    }


                    if(btnBottomFour!=null){
                        btnBottomFour.setText("Remaining energy：" + bottomFour + "kWh");
                    }

                    if(btnBottomFive!=null){
                        btnBottomFive.setText("Remaining energy %：" + NumberUtils.forMatOneNumber(bottomFive * 0.1) + "%");
                    }

                    if(btnBottomSix!=null){
                        btnBottomSix.setText("Battery temperature：" + bottomSix + "℃");
                    }




                    //电池状态 0:空闲,1:充电,2:放电

                    //电池状态 0:空闲,1:充电,2:放电
                    int mBatteryStatus = DataUtils.HexToInt(sendMessage.info[13]);
                    if(!(EmptyUtils.isNotEmpty(EMS客户告警信息0)&&EMS客户告警信息0.contains("电池低电量告警"))){
                        if (mBatteryStatus == 0) {
                            imgPower.setImageResource(R.drawable.image_station_3_0);
                        } else if (mBatteryStatus == 1) {
                            imgPower.setImageResource(R.drawable.image_station_3_2);
                        } else if(mBatteryStatus == 2) {
                            imgPower.setImageResource(R.drawable.image_station_3_3);
                        }
                    }




                    ////////////////////////////////////////////
                    //  BCMU故障告警信息
                    //电池组1客户告警信息1
                    int BCMUA = Integer.parseInt(sendMessage.info[19] + sendMessage.info[18], 16);
                    //电池组1客户告警信息2
                    int BCMUB = Integer.parseInt(sendMessage.info[21] + sendMessage.info[20], 16);
                    //电池组1内部告警信息1
                    int BCMUC = Integer.parseInt(sendMessage.info[23] + sendMessage.info[22], 16);
                    //电池组1内部告警信息2
                    int BCMUD = Integer.parseInt(sendMessage.info[25] + sendMessage.info[24], 16);
                    //电池组1客户故障信息1
                    int BCMUE = Integer.parseInt(sendMessage.info[27] + sendMessage.info[26], 16);
                    //电池组1客户故障信息2
                    int BCMUF = Integer.parseInt(sendMessage.info[29] + sendMessage.info[28], 16);
                    //电池组1内部故障信息1
                    int BCMUG = Integer.parseInt(sendMessage.info[31] + sendMessage.info[30], 16);
                    //电池组1内部故障信息2
                    int BCMUH = Integer.parseInt(sendMessage.info[33] + sendMessage.info[32], 16);
                    BCMU客户告警信息1.clear();
                    //
                    Log.e(TAG, "16进制数: " + BCMUA);
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BCMUA >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BCMUAS[z])) {
                                BCMU客户告警信息1.add(BCMUAS[z]);
                                Log.e(TAG, "accept: " + BCMUAS[z]);
                            }

                        }
                    }

                    BCMU客户告警信息2.clear();
                    for (int a = 0; a < 16; a++) {
                        //每与一次 进位一次
                        if (((BCMUB >> a) & 1) == 1) {
                            if (!TextUtils.isEmpty(BCMUBS[a])) {
                                BCMU客户告警信息2.add(BCMUBS[a]);
                            }


                        }
                    }

                    BCMU内部告警信息1.clear();
                    for (int b = 0; b < 16; b++) {
                        //每与一次 进位一次
                        if (((BCMUC >> b) & 1) == 1) {
                            if (!TextUtils.isEmpty(BCMUCS[b])) {
                                BCMU内部告警信息1.add(BCMUCS[b]);
                            }

                        }
                    }


                    BCMU内部告警信息2.clear();
                    for (int c = 0; c < 16; c++) {
                        //每与一次 进位一次
                        if (((BCMUD >> c) & 1) == 1) {
                            if (!TextUtils.isEmpty(BCMUDS[c])) {
                                BCMU内部告警信息2.add(BCMUDS[c]);
                            }

                        }
                    }


                    //////////////////////////
                    BCMU客户故障信息1.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((BCMUE >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(BCMUES[z])) {
                                BCMU客户故障信息1.add(BCMUES[z]);
                            }

                        }
                    }

                    BCMU客户故障信息2.clear();
                    for (int a = 0; a < 16; a++) {
                        //每与一次 进位一次
                        if (((BCMUF >> a) & 1) == 1) {
                            if (!TextUtils.isEmpty(BCMUFS[a])) {
                                BCMU客户故障信息2.add(BCMUFS[a]);
                            }

                        }
                    }

                    BCMU内部故障信息1.clear();
                    for (int b = 0; b < 16; b++) {
                        //每与一次 进位一次
                        if (((BCMUG >> b) & 1) == 1) {
                            if (!TextUtils.isEmpty(BCMUGS[b])) {
                                BCMU内部故障信息1.add(BCMUGS[b]);
                            }


                        }
                    }


                    BCMU内部故障信息2.clear();
                    for (int c = 0; c < 16; c++) {
                        //每与一次 进位一次
                        if (((BCMUH >> c) & 1) == 1) {
                            if (!TextUtils.isEmpty(BCMUHS[c])) {
                                BCMU内部故障信息2.add(BCMUHS[c]);
                            }


                        }
                    }
                    //BCMU客户告警信息1不为空
                    BCMU故障告警信息List.clear();
                    if (EmptyUtils.isNotEmpty(BCMU客户告警信息1)) {
                        String a = "" + StringUtils.Java7ListToString(BCMU客户告警信息1);
                        BCMU故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(BCMU客户告警信息2)) {
                        String a = "" + StringUtils.Java7ListToString(BCMU客户告警信息2);
                        BCMU故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(BCMU内部告警信息1)) {
                        String a = "" + StringUtils.Java7ListToString(BCMU内部告警信息1);
                        BCMU故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(BCMU内部告警信息2)) {
                        String a = "" + StringUtils.Java7ListToString(BCMU内部告警信息2);
                        BCMU故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(BCMU客户故障信息1)) {
                        String a = "" + StringUtils.Java7ListToString(BCMU客户故障信息1);
                        BCMU故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(BCMU客户故障信息2)) {
                        String a = "" + StringUtils.Java7ListToString(BCMU客户故障信息2);
                        BCMU故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(BCMU内部故障信息1)) {
                        String a = "" + StringUtils.Java7ListToString(BCMU内部故障信息1);
                        BCMU故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(BCMU内部故障信息2)) {
                        String a = "" + StringUtils.Java7ListToString(BCMU内部故障信息2);
                        BCMU故障告警信息List.add(a);
                    }

                    errorsList.set(0, BCMU故障告警信息List);
                    if (EmptyUtils.isNotEmpty(errorsList)) {
                        if(EmptyUtils.isNotEmpty(errorsList.get(0))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(1))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(2))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(3))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(4))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }

                    } else {
                        ivErrors.setVisibility(View.GONE);
                    }


                } else if (DataUtils.HexToInt(sendMessage.info[6]) == 0x92) {//BMU信息上传(0x92)
                    Log.e("实时信息0x92", ":" + Arrays.toString(sendMessage.info));
                    Log.e("实时信息0x92", "BMU信息上传(0x92),对应数据长度:" + length + ",总数据长度:" + sendMessage.info.length);
                } else if (DataUtils.HexToInt(sendMessage.info[6]) == 0x93) {//PCS信息上传(0x93)
                    Log.e("实时信息0x93", ":" + Arrays.toString(sendMessage.info));
                    Log.e("实时信息0x93", "PCS信息上传(0x93),对应数据长度:" + length + ",总数据长度:" + sendMessage.info.length);
                    //EPS功率 （实时数据PCS负载A A相有功功率）
                    Log.e("实时信息", "XXXXEPS功率（实时数据PCS负载A A相有功功率）=" + DataUtils.HexToInt(sendMessage.info[143] + sendMessage.info[142]));
                    //负载功率（实时数据 PCS负载B A有相功率）
                    Log.e("实时信息", "XXXX负载功率（实时数据PCS负载B A相有功功率）=" + DataUtils.HexToInt(sendMessage.info[248] + sendMessage.info[247]));
                    //电网功率（实时数据 PCS A相有功功率（电网侧）  S16 1W(正号表示充电)）
                    Log.e("实时信息", "XXXX电网功率（实时数据 PCS A相有功功率（电网侧））=" + DataUtils.HexToInt(sendMessage.info[101] + sendMessage.info[100]));
                    //逆变器功率（A相有功功率（交流侧）  S16 1W(负号表示充电)
                    Log.e("实时信息", "XXXX逆变器功率（A相有功功率（交流侧））=" + DataUtils.HexToInt(sendMessage.info[59] + sendMessage.info[58]));
                    //逆变器告警111111111111111111111111111111111111111111112

                    //光伏功率（PV1输入端功率+PV2输入端功率） S16 1W(负号表示充电)
                    int pv1 = DataUtils.HexToInt(sendMessage.info[188] + sendMessage.info[187]);
                    int pv2 = DataUtils.HexToInt(sendMessage.info[254] + sendMessage.info[253]);
                    Log.e("实时信息", "XXXX光伏功率（PV1输入端功率+PV2输入端功率）=" + (pv1 + pv2));

                    int value1 = DataUtils.HexToInt(sendMessage.info[143] + sendMessage.info[142]);//EPS
                    int value2 = DataUtils.HexToInt(sendMessage.info[101] + sendMessage.info[100]);//电网
                    int value3 = DataUtils.HexToInt(sendMessage.info[59] + sendMessage.info[58]);//逆变器
                    //光伏功率（PV1输入端功率+PV2输入端功率）
                    value4 = pv1 + pv2;
                    int value5 = DataUtils.HexToInt(sendMessage.info[194] + sendMessage.info[193]);//
                    // count++;
                    //右边的数据
                    tvRight.setText((value1) + "W");//
                    //上边的数据
                    tvTop.setText((value2) + "W");//
                    Log.e(TAG, "上上: "+value2 );
                    //左边的数据
                    tvLeft.setText((value5+value4) + "W");//
                    //中间的数据
                    tvCenter.setText((value3) + "W");//
                    //////////////////////////////////////////
                    //负载功率
                    int value6 = DataUtils.HexToInt(sendMessage.info[248] + sendMessage.info[247]);

                    if (value6 > 0) {
                        imgRight.setImageResource(R.drawable.image_station_1);
                    } else {
                        imgRight.setImageResource(R.drawable.image_station_1_0);
                    }

                    if (value1 > 0) {//右边没有负数 大于零的能量流动 其余的置灰色
                        mViewMainRight.setStatus(1);
                    }
                    else if(value1==0){
                        mViewMainRight.setStatus(2);
                    }
                    else {
                        mViewMainRight.setStatus(1);
                    }


                    if ((value5+value4) > 0) {//左边边没有负数 大于零的能量流动 其余的置灰色
                        mViewMainLeft.setStatus(1);
                    }
                    else if((value5+value4) == 0){
                        mViewMainLeft.setStatus(2);
                    }
                    else {
                        mViewMainLeft.setStatus(0);
                    }



                    if (value2 > 0) {//上边 Grid 大于零向下 等于零灰色 小于零向上
                        mViewMainTop.setStatus(1);
                    } else if (value2 == 0) {
                        mViewMainTop.setStatus(2);
                    } else {
                        mViewMainTop.setStatus(0);
                    }

                    //光伏
                    topOne = DataUtils.HexToInt(sendMessage.info[184] + sendMessage.info[183]);//
                    topTwo = DataUtils.HexToInt(sendMessage.info[186] + sendMessage.info[185]);//
                    topThree = DataUtils.HexToInt(sendMessage.info[188] + sendMessage.info[187]);//
                    topFour = DataUtils.HexToInt(sendMessage.info[190] + sendMessage.info[189]);//
                    topFive = DataUtils.HexToInt(sendMessage.info[192] + sendMessage.info[191]);//
                    topSix = DataUtils.HexToInt(sendMessage.info[194] + sendMessage.info[193]);//

                    if(btnLeftOne!=null){
                        btnLeftOne.setText("PV #1 voltage：" + NumberUtils.forMatOneNumber(topOne * 0.1) + "V");
                    }

                    if(btnLeftTwo!=null){
                        btnLeftTwo.setText("PV #1 current：" + NumberUtils.forMatOneNumber(topTwo * 0.1) + "A");
                    }

                    if(btnLeftThree!=null){

                        btnLeftThree.setText("PV #1 power：" + value4 + "W");
                    }

                    if(btnLeftFour!=null){
                        btnLeftFour.setText("PV #2 voltage：" + NumberUtils.forMatOneNumber(topFour * 0.1) + "V");
                    }

                    if(btnLeftFive!=null){
                        btnLeftFive.setText("PV #2 current：" + NumberUtils.forMatOneNumber(topFive * 0.1) + "A");
                    }

                    if(btnLeftSix!=null){
                        btnLeftSix.setText("PV #2 power：" + topSix + "W");
                    }




                    //EPS
                    leftOne = DataUtils.HexToInt(sendMessage.info[41] + sendMessage.info[40]);//
                    leftTwo = DataUtils.HexToInt(sendMessage.info[137] + sendMessage.info[136]);//
                    leftThree = DataUtils.HexToInt(sendMessage.info[47] + sendMessage.info[46]);//
                    leftFour = DataUtils.HexToInt(sendMessage.info[143] + sendMessage.info[142]);//

                    if(btnRightOne!=null){
                        btnRightOne.setText("EPS output voltage：" + NumberUtils.forMatOneNumber(leftOne * 0.1) + "V");
                    }
                    if(btnRightTwo!=null){
                        btnRightTwo.setText("EPS output current：" + NumberUtils.forMatOneNumber(leftTwo * 0.1) + "A");
                    }
                    if(btnRightThree!=null){
                        btnRightThree.setText("EPS output frequency：" + NumberUtils.forMatNumber(leftThree * 0.01) + "HZ");
                    }


                    if(btnRightFour!=null){
                        btnRightFour.setText("EPS output power：" + leftFour + "W");
                    }





                    //逆变器
                    centerOne = DataUtils.HexToInt(sendMessage.info[59] + sendMessage.info[58]);// 逆变器功率
                    //centerTwo =  DataUtils.HexToInt(sendMessage.info[53] + sendMessage.info[52]);//

                    if(btnCenterOne!=null){
                        btnCenterOne.setText("Inverter power：" + centerOne + "W");
                    }

                    //电网
                    rightOne = DataUtils.HexToInt(sendMessage.info[83] + sendMessage.info[82]);//
                    rightTwo = DataUtils.HexToInt(sendMessage.info[95] + sendMessage.info[94]);//
                    rightThree = DataUtils.HexToInt(sendMessage.info[101] + sendMessage.info[100]);//
                    rightFour = DataUtils.HexToInt(sendMessage.info[89] + sendMessage.info[88]);//


                    if(btnTopOne!=null){
                        btnTopOne.setText("Grid voltage：" + NumberUtils.forMatOneNumber(rightOne * 0.1) + "V");
                    }
                    if(btnTopTwo!=null){
                        btnTopTwo.setText("Grid current：" + NumberUtils.forMatOneNumber(rightTwo * 0.1) + "A");
                    }
                    if(btnTopThree!=null){
                        btnTopThree.setText("Grid power：" + rightThree + "W");
                    }
                    if(btnTopFour!=null){
                        btnTopFour.setText("Grid frequency：" + NumberUtils.forMatNumber(rightFour * 0.01) + "HZ");
                    }






                    //  PCS告警 PCS故障
                    //PCS客户告警信息0
                    int PCSA = Integer.parseInt(sendMessage.info[13] + sendMessage.info[12], 16);
                    //PCS客户告警信息1
                    int PCSB = Integer.parseInt(sendMessage.info[15] + sendMessage.info[14], 16);
                    //PCS客户告警信息2
                    int PCSC = Integer.parseInt(sendMessage.info[17] + sendMessage.info[16], 16);
                    //PCS客户告警信息3
                    int PCSD = Integer.parseInt(sendMessage.info[19] + sendMessage.info[18], 16);
                    //PCS客户告警信息4
                    int PCSE = Integer.parseInt(sendMessage.info[21] + sendMessage.info[20], 16);
                    //PCS客户告警信息5
                    int PCSF = Integer.parseInt(sendMessage.info[23] + sendMessage.info[22], 16);

                    //PCS客户故障信息0
                    int PCSG = Integer.parseInt(sendMessage.info[25] + sendMessage.info[24], 16);
                    //PCS客户故障信息1
                    int PCSH = Integer.parseInt(sendMessage.info[27] + sendMessage.info[26], 16);
                    //PCS客户故障信息2
                    int PCSI = Integer.parseInt(sendMessage.info[29] + sendMessage.info[28], 16);
                    //PCS客户故障信息3
                    int PCSJ = Integer.parseInt(sendMessage.info[31] + sendMessage.info[30], 16);
                    //PCS客户故障信息4
                    int PCSK = Integer.parseInt(sendMessage.info[33] + sendMessage.info[32], 16);
                    //DCDC客户故障信息5
                    int PCSL = Integer.parseInt(sendMessage.info[35] + sendMessage.info[34], 16);


                    PCS客户告警信息0.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSA >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSAS[z])) {
                                PCS客户告警信息0.add(PCSAS[z]);
                            }

                        }
                    }

                    PCS客户告警信息1.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSB >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSBS[z])) {
                                PCS客户告警信息1.add(PCSBS[z]);
                            }

                        }
                    }


                    PCS客户告警信息2.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSC >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSCS[z])) {
                                PCS客户告警信息2.add(PCSCS[z]);
                            }
                        }
                    }


                    PCS客户告警信息3.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSD >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSDS[z])) {
                                PCS客户告警信息3.add(PCSDS[z]);
                            }
                        }
                    }

                    PCS客户告警信息4.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSE >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSES[z])) {
                                PCS客户告警信息4.add(PCSES[z]);
                            }
                        }
                    }


                    PCS客户告警信息5.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSF >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSFS[z])) {
                                PCS客户告警信息5.add(PCSFS[z]);
                            }
                        }
                    }


                    PCS客户故障信息0.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSG >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSGS[z])) {
                                PCS客户故障信息0.add(PCSGS[z]);
                            }

                        }
                    }

                    PCS客户故障信息1.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSH >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSHS[z])) {
                                PCS客户故障信息1.add(PCSHS[z]);
                            }

                        }
                    }


                    PCS客户故障信息2.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSI >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSIS[z])) {
                                PCS客户故障信息2.add(PCSIS[z]);
                            }
                        }
                    }


                    PCS客户故障信息3.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSJ >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSJS[z])) {
                                PCS客户故障信息3.add(PCSJS[z]);
                            }
                        }
                    }

                    PCS客户故障信息4.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSK >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSKS[z])) {
                                PCS客户故障信息4.add(PCSKS[z]);
                            }
                        }
                    }


                    PCS客户故障信息5.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((PCSL >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(PCSLS[z])) {
                                PCS客户故障信息5.add(PCSLS[z]);
                            }
                        }
                    }

                    PCS故障告警信息List.clear();
                    //DCDC故障
                    if (EmptyUtils.isNotEmpty(PCS客户告警信息0)) {
                        String a = "" + StringUtils.Java7ListToString(PCS客户告警信息0);
                        PCS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(PCS客户告警信息1)) {
                        String a = "" +StringUtils.Java7ListToString(PCS客户告警信息1);
                        PCS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(PCS客户告警信息2)) {
                        String a = "" + StringUtils.Java7ListToString(PCS客户告警信息2);
                        PCS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(PCS客户告警信息3)) {
                        String a = "" +  StringUtils.Java7ListToString(PCS客户告警信息3);
                        PCS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(PCS客户告警信息4)) {
                        String a = "" + StringUtils.Java7ListToString(PCS客户告警信息4);
                        PCS故障告警信息List.add(a);
                    }
                    if (EmptyUtils.isNotEmpty(PCS客户告警信息5)) {
                        String a = "" + StringUtils.Java7ListToString(PCS客户告警信息5);
                    }


                    //PCS故障
                    if (EmptyUtils.isNotEmpty(PCS客户故障信息0)) {
                        String a = "" + StringUtils.Java7ListToString(PCS客户故障信息0);
                        PCS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(PCS客户故障信息1)) {
                        String a = "" + StringUtils.Java7ListToString(PCS客户故障信息1);
                        PCS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(PCS客户故障信息2)) {
                        String a = "" + StringUtils.Java7ListToString(PCS客户故障信息2);
                        PCS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(PCS客户故障信息3)) {
                        String a = "" +StringUtils.Java7ListToString(PCS客户故障信息3);
                        PCS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(PCS客户故障信息4)) {
                        String a = "" + StringUtils.Java7ListToString(PCS客户故障信息4);
                        PCS故障告警信息List.add(a);
                    }
                    if (EmptyUtils.isNotEmpty(PCS客户故障信息5)) {
                        String a = "" +StringUtils.Java7ListToString(PCS客户故障信息5);
                        PCS故障告警信息List.add(a);
                    }
                    errorsList.set(2, PCS故障告警信息List);
                    if (EmptyUtils.isNotEmpty(errorsList)) {
                        if(EmptyUtils.isNotEmpty(errorsList.get(0))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(1))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(2))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(3))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(4))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }

                    } else {
                        ivErrors.setVisibility(View.GONE);
                    }

                    //
                    //  DCDC告警 DCDC故障
                    //DCDC客户告警信息0
                    int DCDCA = Integer.parseInt(sendMessage.info[206] + sendMessage.info[205], 16);
                    //DCDC客户告警信息1
                    int DCDCB = Integer.parseInt(sendMessage.info[208] + sendMessage.info[207], 16);
                    //DCDC客户告警信息2
                    int DCDCC = Integer.parseInt(sendMessage.info[210] + sendMessage.info[209], 16);
                    //DCDC客户告警信息3
                    int DCDCD = Integer.parseInt(sendMessage.info[212] + sendMessage.info[211], 16);
                    //DCDC客户告警信息4
                    int DCDCE = Integer.parseInt(sendMessage.info[214] + sendMessage.info[213], 16);
                    //DCDC客户告警信息5
                    int DCDCF = Integer.parseInt(sendMessage.info[216] + sendMessage.info[215], 16);
                    //DCDC客户故障信息0
                    int DCDCG = Integer.parseInt(sendMessage.info[218] + sendMessage.info[217], 16);
                    //DCDC客户故障信息1
                    int DCDCH = Integer.parseInt(sendMessage.info[220] + sendMessage.info[219], 16);
                    //DCDC客户故障信息2
                    int DCDCI = Integer.parseInt(sendMessage.info[222] + sendMessage.info[221], 16);
                    //DCDC客户故障信息3
                    int DCDCJ = Integer.parseInt(sendMessage.info[224] + sendMessage.info[223], 16);
                    //DCDC客户故障信息4
                    int DCDCK = Integer.parseInt(sendMessage.info[226] + sendMessage.info[225], 16);
                    //DCDC客户故障信息5
                    int DCDCL = Integer.parseInt(sendMessage.info[228] + sendMessage.info[227], 16);


                    DCDC客户告警信息0.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCA >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCAS[z])) {
                                DCDC客户告警信息0.add(DCDCAS[z]);
                            }

                        }
                    }


                    DCDC客户告警信息1.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCB >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCBS[z])) {
                                DCDC客户告警信息1.add(DCDCBS[z]);
                            }

                        }
                    }


                    DCDC客户告警信息2.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCC >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCCS[z])) {
                                DCDC客户告警信息2.add(DCDCCS[z]);
                            }

                        }
                    }


                    DCDC客户告警信息3.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCD >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCDS[z])) {
                                DCDC客户告警信息3.add(DCDCDS[z]);
                            }

                        }
                    }


                    DCDC客户告警信息4.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCE >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCES[z])) {
                                DCDC客户告警信息4.add(DCDCES[z]);
                            }

                        }
                    }


                    DCDC客户告警信息5.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCF >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCFS[z])) {
                                DCDC客户告警信息5.add(DCDCFS[z]);
                            }

                        }
                    }


                    DCDC客户故障信息0.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCG >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCGS[z])) {
                                DCDC客户故障信息0.add(DCDCGS[z]);
                            }

                        }
                    }


                    DCDC客户故障信息1.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCH >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCHS[z])) {
                                DCDC客户故障信息1.add(DCDCHS[z]);
                            }

                        }
                    }

                    DCDC客户故障信息2.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCI >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCIS[z])) {
                                DCDC客户故障信息2.add(DCDCIS[z]);
                            }

                        }
                    }


                    DCDC客户故障信息3.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCJ >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCJS[z])) {
                                DCDC客户故障信息3.add(DCDCJS[z]);
                            }

                        }
                    }


                    DCDC客户故障信息4.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCK >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCKS[z])) {
                                DCDC客户故障信息4.add(DCDCKS[z]);
                            }

                        }
                    }


                    DCDC客户故障信息5.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((DCDCL >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(DCDCLS[z])) {
                                DCDC客户故障信息5.add(DCDCLS[z]);
                            }

                        }
                    }


                    DCDC故障告警信息List.clear();
                    //DCDC故障
                    if (EmptyUtils.isNotEmpty(DCDC客户告警信息0)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户告警信息0);
                        DCDC故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(DCDC客户告警信息1)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户告警信息1);
                        DCDC故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(DCDC客户告警信息2)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户告警信息2);
                        DCDC故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(DCDC客户告警信息3)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户告警信息3);
                        DCDC故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(DCDC客户告警信息4)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户告警信息4);
                        DCDC故障告警信息List.add(a);
                    }
                    if (EmptyUtils.isNotEmpty(DCDC客户告警信息5)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户告警信息5);
                        DCDC故障告警信息List.add(a);
                    }

                    //DCDC故障
                    if (EmptyUtils.isNotEmpty(DCDC客户故障信息0)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户故障信息0);
                        DCDC故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(DCDC客户故障信息1)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户故障信息1);
                        DCDC故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(DCDC客户故障信息2)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户故障信息1);
                        DCDC故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(DCDC客户故障信息3)) {
                        String a = "" + StringUtils.Java7ListToString(DCDC客户故障信息1);
                        DCDC故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(DCDC客户故障信息4)) {
                        String a = ":" +  StringUtils.Java7ListToString(DCDC客户故障信息4);
                        DCDC故障告警信息List.add(a);
                    }
                    if (EmptyUtils.isNotEmpty(DCDC客户故障信息5)) {
                        String a = "" +StringUtils.Java7ListToString(DCDC客户故障信息5);
                        DCDC故障告警信息List.add(a);
                    }

                    errorsList.set(3, DCDC故障告警信息List);
                    if (EmptyUtils.isNotEmpty(errorsList)) {
                        if(EmptyUtils.isNotEmpty(errorsList.get(0))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(1))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(2))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(3))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(4))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }

                    } else {
                        ivErrors.setVisibility(View.GONE);
                    }


                } else if (DataUtils.HexToInt(sendMessage.info[6]) == 0x94) {//EMS信息上传(0x94)
                    Log.e("实时信息0x94", ":" + Arrays.toString(sendMessage.info));
                    Log.e("实时信息0x94", "EMS信息上传(0x94),对应数据长度:" + length + ",总数据长度:" + sendMessage.info.length);
                    Log.e("实时信息0x94", "系统工作模式: " + DataUtils.HexToInt(sendMessage.info[12]));
                    if (DataUtils.HexToInt(sendMessage.info[12]) >= 0) {
                        tvMode.setText("Current operating mode：" + modes[DataUtils.HexToInt(sendMessage.info[12])]);
                    }
                    //
                    //  EMS告警
                    //EMS客户告警信息0
                    int EMSA = Integer.parseInt(sendMessage.info[14] + sendMessage.info[13], 16);
                    //EMS客户告警信息1
                    int EMSB = Integer.parseInt(sendMessage.info[16] + sendMessage.info[15], 16);
                    //EMS客户告警信息2
                    int EMSC = Integer.parseInt(sendMessage.info[18] + sendMessage.info[17], 16);
                    //EMS客户告警信息3
                    int EMSD = Integer.parseInt(sendMessage.info[20] + sendMessage.info[19], 16);
                    //EMS客户告警信息4
                    int EMSE = Integer.parseInt(sendMessage.info[22] + sendMessage.info[21], 16);
                    //EMS客户告警信息5
                    int EMSF = Integer.parseInt(sendMessage.info[24] + sendMessage.info[23], 16);
                    //EMS客户故障信息0
                    int EMSG = Integer.parseInt(sendMessage.info[26] + sendMessage.info[25], 16);
                    //EMS客户故障信息1
                    int EMSH = Integer.parseInt(sendMessage.info[28] + sendMessage.info[27], 16);

                    //EMS客户故障信息2
                    int EMSI = Integer.parseInt(sendMessage.info[30] + sendMessage.info[29], 16);
                    //EMS客户故障信息3
                    int EMSJ = Integer.parseInt(sendMessage.info[32] + sendMessage.info[31], 16);
                    //EMS客户故障信息4
                    int EMSK = Integer.parseInt(sendMessage.info[34] + sendMessage.info[33], 16);
                    //EMS客户故障信息5
                    int EMSL = Integer.parseInt(sendMessage.info[36] + sendMessage.info[35], 16);


                    EMS客户告警信息0.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((EMSA >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSAS[z])) {
                                EMS客户告警信息0.add(EMSAS[z]);
                                Log.e(TAG, "accept: " + EMSAS[z]);
                            }

                        }
                    }
                    if(EmptyUtils.isNotEmpty(EMS客户告警信息0)&&EMS客户告警信息0.contains("电池低电量告警")){
                        imgPower.setImageResource(R.drawable.image_station_3_1);
                    }
                    EMS客户告警信息1.clear();
                    for (int a = 0; a < 16; a++) {
                        //每与一次 进位一次
                        if (((EMSB >> a) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSBS[a])) {
                                EMS客户告警信息1.add(EMSBS[a]);
                            }


                        }
                    }

                    EMS客户告警信息2.clear();
                    for (int b = 0; b < 16; b++) {
                        //每与一次 进位一次
                        if (((EMSC >> b) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSCS[b])) {
                                EMS客户告警信息2.add(EMSCS[b]);
                            }

                        }
                    }


                    EMS客户告警信息3.clear();
                    for (int c = 0; c < 16; c++) {
                        //每与一次 进位一次
                        if (((EMSD >> c) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSDS[c])) {
                                EMS客户告警信息3.add(EMSDS[c]);
                            }

                        }
                    }


                    EMS客户告警信息4.clear();
                    for (int z = 0; z < 16; z++) {
                        //每与一次 进位一次
                        if (((EMSE >> z) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSES[z])) {
                                EMS客户告警信息4.add(EMSES[z]);
                            }

                        }
                    }

                    EMS客户告警信息5.clear();
                    for (int a = 0; a < 16; a++) {
                        //每与一次 进位一次
                        if (((EMSF >> a) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSFS[a])) {
                                EMS客户告警信息5.add(EMSFS[a]);
                            }

                        }
                    }

                    EMS客户故障信息0.clear();
                    for (int b = 0; b < 16; b++) {
                        //每与一次 进位一次
                        if (((EMSG >> b) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSGS[b])) {
                                EMS客户故障信息0.add(EMSGS[b]);
                            }


                        }
                    }


                    EMS客户故障信息1.clear();
                    for (int c = 0; c < 16; c++) {
                        //每与一次 进位一次
                        if (((EMSH >> c) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSHS[c])) {
                                EMS客户故障信息1.add(EMSHS[c]);
                            }
                        }
                    }


                    EMS客户故障信息2.clear();
                    for (int b = 0; b < 16; b++) {
                        //每与一次 进位一次
                        if (((EMSI >> b) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSIS[b])) {
                                EMS客户故障信息2.add(EMSIS[b]);
                            }


                        }
                    }


                    EMS客户故障信息3.clear();
                    for (int c = 0; c < 16; c++) {
                        //每与一次 进位一次
                        if (((EMSJ >> c) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSJS[c])) {
                                EMS客户故障信息3.add(EMSJS[c]);
                            }
                        }
                    }

                    EMS客户故障信息4.clear();
                    for (int b = 0; b < 16; b++) {
                        //每与一次 进位一次
                        if (((EMSK >> b) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSKS[b])) {
                                EMS客户故障信息4.add(EMSKS[b]);
                            }


                        }
                    }


                    EMS客户故障信息5.clear();
                    for (int c = 0; c < 16; c++) {
                        //每与一次 进位一次
                        if (((EMSL >> c) & 1) == 1) {
                            if (!TextUtils.isEmpty(EMSLS[c])) {
                                EMS客户故障信息5.add(EMSLS[c]);
                            }
                        }
                    }


                    EMS故障告警信息List.clear();
                    if (EmptyUtils.isNotEmpty(EMS客户告警信息0)) {
                        String a = "" + StringUtils.Java7ListToString(EMS客户告警信息0);
                        EMS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(EMS客户告警信息1)) {
                        String a = "" + StringUtils.Java7ListToString(EMS客户告警信息1);
                        EMS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(EMS客户告警信息2)) {
                        String a = "" +  StringUtils.Java7ListToString(EMS客户告警信息2);
                        EMS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(EMS客户告警信息3)) {
                        String a = "" + StringUtils.Java7ListToString(EMS客户告警信息3);
                        EMS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(EMS客户告警信息4)) {
                        String a = "" +StringUtils.Java7ListToString(EMS客户告警信息4);
                        EMS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(EMS客户告警信息5)) {
                        String a = "" +  StringUtils.Java7ListToString(EMS客户告警信息5);
                        EMS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(EMS客户故障信息0)) {

                        String a = "" + StringUtils.Java7ListToString(EMS客户故障信息0);
                        EMS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(EMS客户故障信息1)) {

                        String a = "" +    StringUtils.Java7ListToString(EMS客户故障信息1);
                        EMS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(EMS客户故障信息2)) {


                        String a = "" + StringUtils.Java7ListToString(EMS客户故障信息2);
                        EMS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(EMS客户故障信息3)) {


                        String a = "" +  StringUtils.Java7ListToString(EMS客户故障信息3);;
                        EMS故障告警信息List.add(a);
                    }

                    if (EmptyUtils.isNotEmpty(EMS客户故障信息4)) {
                        String a = "" +  StringUtils.Java7ListToString(EMS客户故障信息4);
                        EMS故障告警信息List.add(a);
                    }


                    if (EmptyUtils.isNotEmpty(EMS客户故障信息5)) {
                        String a = "" +  StringUtils.Java7ListToString(EMS客户故障信息5);
                        EMS故障告警信息List.add(a);
                    }

                    errorsList.set(4, EMS故障告警信息List);
                    if (EmptyUtils.isNotEmpty(errorsList)) {
                        if(EmptyUtils.isNotEmpty(errorsList.get(0))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(1))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(2))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(3))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }
                        if(EmptyUtils.isNotEmpty(errorsList.get(4))){
                            ivErrors.setVisibility(View.VISIBLE);
                        }

                    } else {
                        ivErrors.setVisibility(View.GONE);
                    }

                } else if (DataUtils.HexToInt(sendMessage.info[6]) == 0x95) {//事件信息上传(0x95)
                    Log.e("实时信息0x95", ":" + Arrays.toString(sendMessage.info));
                    Log.e("实时信息0x95", "事件信息上传(0x95),对应数据长度:" + length + ",总数据长度:" + sendMessage.info.length);


                }
            }
        }

        //  查询命令
        if (sendMessage != null && sendMessage.readContent[2] == SocketConfig.SEARCH) {
            Log.e("查询命令", "我接收到了查询命令的所有数据(已过滤传输规则中其他数据):" + Arrays.toString(sendMessage.info));
            Log.e("查询命令", "前六位是年月日时分秒:" + DataUtils.HexToInt(sendMessage.info[0]) + "年" + DataUtils.HexToInt(sendMessage.info[1]) + "月" + DataUtils.HexToInt(sendMessage.info[2]) + "日" + DataUtils.HexToInt(sendMessage.info[3]) + "时" + DataUtils.HexToInt(sendMessage.info[4]) + "分" + DataUtils.HexToInt(sendMessage.info[5]) + "秒");

        } else if (sendMessage != null) {
            Log.e("设置信息", "我接收到了实时信息的所有数据(已过滤传输规则中其他数据):" + Arrays.toString(sendMessage.info));

        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                if (sendMessage != null && sendMessage.readContent[3] == (byte) 0xFE) {
                    Log.e("浪", "为了保持app的Socket通信，设备基本会实时发送数据，在应答标志为FE时就发送一次消息，确认信息获取成功");
                    SocketUtils.sendSerialPort(SocketConfig.settingVehicleAccess(sendMessage.readContent));
                }
            }
        }).start();


    }

}
